﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:controls="clr-namespace:Framework.UI.Controls"
                    xmlns:params="http://schemas.codeplex.com/elysium/params">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/Elysium;component/Themes/Generic.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style TargetType="{x:Type controls:CalloutContentControl}">
        <Setter Property="ArrowAlignment" Value="Left"/>
        <Setter Property="ArrowHeight" Value="30"/>
        <Setter Property="ArrowPlacement" Value="Top"/>
        <Setter Property="ArrowWidth" Value="30"/>
        <Setter Property="Background" Value="{StaticResource BackgroundBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource MiddleLightBrush}"/>
        <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultThickness), Mode=OneWay}"/>
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type controls:CalloutContentControl}">
                    <ControlTemplate.Resources>
                        <controls:CalloutContentControlToThicknessConverter x:Key="CalloutContentControlToThicknessConverter"/>
                    </ControlTemplate.Resources>
                    <Grid x:Name="Grid">
                        <Grid.RenderTransform>
                            <TransformGroup>
                                <ScaleTransform/>
                                <SkewTransform/>
                                <RotateTransform/>
                                <TranslateTransform/>
                            </TransformGroup>
                        </Grid.RenderTransform>

                        <Grid Margin="0, 8, 10, 22">
                            <Border SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                                <Border.Effect>
                                    <BlurEffect Radius="10" RenderingBias="Quality"/>
                                </Border.Effect>
                                <controls:CalloutShape ArrowAlignment="{TemplateBinding ArrowAlignment}" 
                                                       ArrowHeight="{TemplateBinding ArrowHeight}" 
                                                       ArrowPlacement="{TemplateBinding ArrowPlacement}" 
                                                       ArrowWidth="{TemplateBinding ArrowWidth}" 
                                                       Fill="#90000000"
                                                       Margin="4, 0, 8, 2" 
                                                       RenderTransformOrigin="0.507, 0.861" 
                                                       StrokeThickness="0" >
                                    <controls:CalloutShape.RenderTransform>
                                        <TransformGroup>
                                            <SkewTransform AngleY="3.5"/>
                                            <TranslateTransform Y="8.0"/>
                                        </TransformGroup>
                                    </controls:CalloutShape.RenderTransform>
                                </controls:CalloutShape>
                            </Border>
                        </Grid>

                        <controls:CalloutShape ArrowAlignment="{TemplateBinding ArrowAlignment}" 
                                               ArrowHeight="{TemplateBinding ArrowHeight}" 
                                               ArrowPlacement="{TemplateBinding ArrowPlacement}" 
                                               ArrowWidth="{TemplateBinding ArrowWidth}" 
                                               Fill="{TemplateBinding Background}"
                                               Margin="0, 0, 0, 25" 
                                               Stroke="{TemplateBinding BorderBrush}"
                                               StrokeThickness="{TemplateBinding BorderThickness}"/>

                        <Grid Margin="0, 0, 0, 25">
                            <Grid Margin="{TemplateBinding BorderThickness}">
                                <ContentPresenter x:Name="ContentPresenter"
                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                  Margin="{Binding Converter={StaticResource CalloutContentControlToThicknessConverter}, RelativeSource={RelativeSource TemplatedParent}}"
                                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            </Grid>
                        </Grid>

                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="BorderBrush" Value="{StaticResource AccentBrush}"/>
            </Trigger>
        </Style.Triggers>
    </Style>

</ResourceDictionary>